#!/bin/bash
cd $(dirname $(readlink -f "$0"))
url=http://172.16.98.140:8088/gateway/gateway-0.0.1-SNAPSHOT.jar

now=`cat latest.sha256sum`
latest=`curl "$url.sha256sum"`

if [[ "co$now" != "co$latest" ]]; then
	rm -f jar/gateway-0.0.1-SNAPSHOT.old.jar
	mv jar/gateway-0.0.1-SNAPSHOT.jar jar/gateway-0.0.1-SNAPSHOT.old.jar
	curl -o jar/gateway-0.0.1-SNAPSHOT.jar "$url"
	echo "$latest" > latest.sha256sum
	./upgateway.sh
	echo "update done"
fi
